<template>
  <div>
    <!--顶部搜索 -->
    <div class="header">
      <div class="header-center" :style="{width:language == 'en' ? '70%' : ''}">
        <div class="headertitle">
          HIREM-DB
        </div>
        <div class="headerrig" :style="{width:language == 'en' ? '85%' : ''}">
          <div class="pageList">
            <div class="pageitem" v-for="(item,index) in navArr" :key="index" @click="changepage(item,index)">
              <div class="inpageitem" :style="{color:index == linkActive ? '#0d48ba' : ''}">
                <span style="padding: 0 8px;">
                  {{language == 'zh' ? item.name : item.English}}
                </span>
                <div class="botborder" :style="{backgroundColor:index == linkActive ? '#0d48ba' : 'transparent'}"></div>
              </div>
            </div>
          </div>
          <div class="language">
            <div style="display: flex;align-items: center;" @click="changelangua()">
              <span style="font-size: 14px;color: #999999;cursor: pointer;margin-bottom: 12px;" v-if="language == 'zh'">
                中文
              </span>
              <span style="font-size: 14px;color: #999999;cursor: pointer;margin-bottom: 12px;" v-else>
                English
              </span>
              <img src="../img/language.png" alt=""
                style="height: 15px;width: 15px;cursor: pointer;margin-bottom: 10px;margin-left: 5px;">
            </div>
          </div>
        </div>
      </div>
    </div>
    <router-view></router-view>
    <!-- 底部 -->
    <div class="bottBox">
      <div class="bottBox-cent">
        <div class="bottBox-cent-contact clearfix">
          <div class="bottBox_left">
            <div class="yszc" v-if="language == 'zh'" style="width: 88px;" @click="toyszc()">
              隐私政策
            </div>
            <div class="yszc" v-else style="width: 155px;" @click="toyszc()">
              Privacy Policy
            </div>
          </div>
          <div class="bottBox_mid">
            <div class="callme" v-if="language == 'zh'" style="width: 88px;">
              联系我们
            </div>
            <div class="callme" v-else style="width: 155px;">
              Contact Us
            </div>
            <div class="address1" v-for="(item,index) in callmeList" :key="index" :style="{marginTop:index != 0 ? '30px' : '40px'}">
              <span>{{item.cTitle}}: </span>
              <span>{{item.cSubtitle}}</span>
            </div>
          </div>
          <div class="bottBox_mid">
            <div class="callme" v-if="language == 'zh'" style="width: 88px;">
              友情链接
            </div>
            <div class="callme" v-else style="width: 155px;">
              Friendship link
            </div>
            <div class="twocontent">
              <div class="twoitem" v-for="(item,index) in linkList" :key="index">
                <div class="itemleft" v-for="(it,idx) in item" :key="idx" @click="tolink(it)">
                  {{it.cTitle}}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="bottBox_bot">
        <div class="inbottBox_bot">
          版权信息: {{Copyright}}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: "HelloWorld",
    props: [],
    components: {},
    data() {
      return {
        navArr: [
          { id: 0, name: "首页", English: 'Home Page', link: "/" },
          { id: 1, name: "转录组数据", English: 'Transcriptome Data', link: "/zlzsj" },
          { id: 2, name: "差异疾病生物标志物", English: 'Differential Disease Biomarkers', link: "/cyjbswbzw" },
          { id: 3, name: "文献命名实体识别", English: 'Document Naming Entity Recognition', link: "/literature" },
          { id: 4, name: "临床预测", English: 'Clinical Prediction', link: "" }
        ],
        linkActive: 0,
        searVal: "",
        routerlist: false,
        footerArr: [],
        footerActive: 9,
        language: 'zh',
        nowpage: '',
        linkList: [],
        callmeList: [],
        Copyright: null
      };
    },
    watch: {
      $route(to, from) {
        console.log(to.path)
        if (to.path == '/') {
          this.linkActive = 0;
        }else if(to.path == '/zlzsj'){
          this.linkActive = 1
        }else if(to.path == '/cyjbswbzw'){
          this.linkActive = 2
        }else if(to.path == '/literature'){
          this.linkActive = 3
        }
      }
    },
    created() {
      this.$addStorageEvent(2, "language", this.language)
    },
    methods: {
      // 切换语言
      changelangua() {
        if (this.language == 'zh') {
          this.language = 'en'
        } else {
          this.language = 'zh'
        }
        this.$addStorageEvent(2, "language", this.language)
        this.getData()
      },
      // 切换页面
      changepage(item, index) {
        this.$router.push(item.link)
        this.linkActive = index
      },
      // 获取底部导航栏数据
      async getData() {
        // 友情链接
        await this.axios
          .get('/system/content/list?pageNum=1&pageSize=100&cState=1&cDataType=3&cLanguage=' + this.language).then(res => {
            if (res.data.code == 200) {
              this.linkList = this.groupList(res.data.rows,2)
              console.log(this.linkList,'*-*-')
            }
          })
        // 联系我们
        await this.axios
          .get('/system/content/list?pageNum=1&pageSize=20&cState=1&cDataType=8&cLanguage=' + this.language).then(res => {
            if (res.data.code == 200) {
              this.callmeList = res.data.rows
            }
          })
        // 版权信息
        await this.axios
          .get('/system/content/list?pageNum=1&pageSize=10&cState=1&cDataType=7&cLanguage=' + this.language).then(res => {
            if (res.data.code == 200) {
              if(res.data.rows && res.data.rows.length != 0){
                this.Copyright = res.data.rows[0].cTitle
              }
            }
          })
      },
      groupList(array, subGroupLength) {
        let index = 0;
        let newArray = [];
        while (index < array.length) {
          newArray.push(array.slice(index, index += subGroupLength));
        }
        return newArray;
      },
      // 友情链接点击
      tolink(item){
        window.open(item.cSubtitle,'_blank')
      },
      // 跳转隐私政策
      toyszc(){
        this.$router.push('/PrivacyPolicy')
      }
    },
    mounted() {
      this.getData()
    }
  };
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  /* 顶部 */
  .header-center {
    width: 70%;
    height: 70px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
  }

  .headerrig {
    display: flex;
    align-items: center;
    width: 70%;
    justify-content: space-between
  }

  .header {
    width: 100%;
    background: #fff;
  }

  .headertitle {
    color: #0d48ba;
    font-size: 22px;
    font-weight: 600;
  }

  .pageList {
    display: flex;
    align-items: center;
  }

  .pageitem {
    margin-right: 10px;
    cursor: pointer;
  }

  .inpageitem {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 16px;
  }

  .botborder {
    width: 48px;
    margin-top: 4px;
    height: 6px;
    border-radius: 6px;
  }

  .language {
    font-size: 14px;
    color: #999999;
    display: flex;
    align-items: center;
    height: 100%;
  }

  /* 底部 */
  .bottBox-ICP {
    padding: 28px 0;
    font-size: 12px;
    color: rgb(184, 184, 184);
    text-align: center;
    border-top: 1px solid rgb(112, 112, 112);
  }

  .cent-contact-right ul li {
    width: 108px;
    text-align: center;
    height: 40px;
    background: rgba(120, 120, 120, 1);
    line-height: 40px;
    margin-right: 30px;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    display: inline-block;
    margin-bottom: 20px;
    font-size: 14px;
  }

  .posters:hover {
    display: block;
  }

  .posters {
    width: 110px;
    height: 180px;
    position: absolute;
    right: 0;
    top: 65px;
    z-index: 100;
    box-sizing: border-box;
    padding-top: 35px;
  }

  .toux {
    width: 48px;
    height: 48px;
    border-radius: 50%;
  }

  .cent-contact-right ul li.active {
    background: rgba(148, 148, 148, 1);
  }

  .cent-contact-right ul {
    /* display: inline-block; */
    /* display: flex; */
  }

  .cent-contact-right p {
    color: #fff;
    font-size: 20px;
    margin-bottom: 28px;
    margin-top: 14px;
  }

  .cent-contact-right p.huiWord {
    font-size: 16px;
    margin-bottom: 14px;
  }

  .cent-contact-right {
    width: 33.3%;
    /* height: 100px; */
    float: left;
    position: relative;
  }

  .shuLine {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 0px;
    width: 1px;
    height: 40px;
    background: rgba(255, 255, 255, 0.6);
    /* background: red; */
    display: inline-block;
  }

  .bottomTit {
    position: absolute;
    top: -80px;
    left: 0px;
    color: rgba(255, 255, 255, 1);
    font-size: 32px;
  }

  .bottomTit span {
    color: rgba(255, 255, 255, 1);
    font-size: 20px;
    padding-left: 20px;
  }

  .bottBox {
    width: 100%;
    background-color: #2c3e50;
    padding: 30px 0;
    padding-bottom: 0;
    box-sizing: border-box;
  }

  .bottBox-cent {
    width: 70%;
    margin: 0 auto;
  }

  .bottBox-cent-contact {
    display: flex;
    justify-content: space-between;
  }

  .yszc {
    padding: 0 0 10px 0;
    box-sizing: border-box;
    border-bottom: 3px solid #0a86d5;
    color: #0a86d5;
    font-size: 22px;
    cursor: pointer;
    width: 88px;
    text-align: center;
  }

  .bottBox_mid {}

  .callme {
    padding: 0 0 10px 0;
    box-sizing: border-box;
    border-bottom: 3px solid #fff;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    width: 88px;
    text-align: center;
  }

  .address1 {
    margin-top: 30px;
    color: #fff;
    font-size: 18px;
  }
  .twoitem:first-child{
    margin-top: 40px;
  }
  .twoitem {
    color: #fff;
    font-size: 18px;
    margin-top: 30px;
    display: flex;
    align-items: center;
    cursor: pointer;
  }

  .itemleft {
    margin-right: 70px;
  }

  .bottBox_bot {
    border-top: 2px solid #9da5ad;
    margin-top: 28px;
    padding: 14px 0;
    box-sizing: border-box;
  }

  .inbottBox_bot {
    width: 38%;
    margin: 0 auto;
    color: #fff;
    font-size: 16px;
  }
</style>